{extend name="base" /}{block name="seo"}
<title>充值中心 - {$site.name}</title>
<meta name="keywords" content="{$site.keywords}">
<meta name="description" content="{$site.description}">
{/block}
{block name="css"}
<link href="__HOME__/css/user.css" rel="stylesheet" type="text/css">
<style>
    .tr_rechtext {
        width: 100%;
        padding: 10px;
        background: #dedede;
        color: #333;
    }
    .te_retit {
        font-size: 20px;
        font-weight: bold;
        line-height: 40px;
    }
</style>
{/block}
{block name="body"}
<div class="container">
    <div class="user">
        {include file="index/menu"}
        <div class="user-info user-box fl">
            <div class="title">
                充值中心 <span style="line-height:30px;float: right"><a href="/user/score/recharge_log.html">充值记录</a></span>
             </div>

            <div class="layui-tab layui-tab-brief tr_recharge">
                <?php $scoreName=sysconfig('score.score_name'); ?>
                <div class="tr_rechtext">
                    <p class="te_retit"><img src="/public//images/coin.png" alt="">充值说明</p>
                    <p>{$scoreName}是本站唯一交易介质，你可以使用{$scoreName}购买站内的付费内容和打赏作者。</p>
                    <p>1金币={$scoreConfig.score_price}元，每次{$scoreConfig.min_recharge}{$scoreName}起充。</p>
                    <p>支付过程中请勿关闭扫码付款页面，以免充值失败。</p>
                </div>
                <div class="layui-form layui-form-pane" style="padding: 20px 0;">
                    <form method="post">
                        <input type="hidden"  name="subject" value="RECHARGE" class="layui-input">
                        <div class="layui-form-item">

                            <label for="L_title" class="layui-form-label">充值金币</label>
                            <div class="layui-input-inline">
                                <input type="number" min="1" value="{$scoreConfig.min_recharge}"  name="subject_num" id="score" required="" lay-verify="required" autocomplete="off" class="layui-input">
                            </div>

                            <div class="layui-form-mid layui-word-aux">最少充值{$scoreConfig.min_recharge}{$scoreName}</div>

                        </div>
                        <div class="layui-form-item">
                            <label  class="layui-form-label">金额</label>
                            <div class="layui-input-inline">
                                <input type="number"  id="money" disabled="" value="{$scoreConfig.score_price*$scoreConfig.min_recharge}" class="layui-input">
                            </div>
                        </div>
                        <?php $pays=sysconfig('score.deposit_payments'); if($pays){ $pays=explode(',',$pays); ?>
                        <div class="layui-form-item" style="line-height:50px">

                            <label class="layui-form-label">付款方式</label>
                            <div class="layui-input-block">
                                    {volist  name="pays" id="vo"}
                                    <input type="radio" name="pay_type" value="{$vo}" title="" {if $key eq 0}checked{/if}>
                                <div lay-radio=""> <img src="__STATIC__/common/images/{$vo}.png" title="{$vo}" style="top: -1px;width: 130px;height: 40px;"/></div>
                                    {/volist}
                            </div>
                        </div>
                                <?php }?>
                        <div class="layui-form-item">

                            <div class="layui-input-block">
                            <button class="layui-btn" lay-submit="" lay-filter="forum_pay">确认支付</button>
                            <button onclick="history.go(-1);" class="layui-btn layui-btn-primary ">返回</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}

<script>
    layui.use(["form"], function () {
        let form = layui.form;
        var jiage = {$scoreConfig.score_price};
        $('#score').on('focusout', function() {
            var scorenum = $(this).val();
            var score = (jiage * scorenum).toFixed(2);
            $('#money').val(score);
        });
        form.on('submit(forum_pay)', function(data){
            if($("input[name='score']").eq(0).val() == ""){
                layer.msg('请输入充值的金币数量');
                $("input[name='score']").focus();return false;
            }
            var params=data.field;

            window.open(config.api.order_create+'?pay_type='+params.pay_type+'&subject='+params.subject+'&subject_num='+params.subject_num);
            // var index = layer.open({
            //     type: 2,
            //     closeBtn: 1, //不显示关闭按钮
            //     title: '收银台',
            //     content: config.api.order_create+'?pay_type='+params.pay_type+'&subject='+params.subject+'&subject_num='+params.subject_num,
            //     area: ['400px', '443px'],
            // });
            // $.ajax({
            //     cache: true,
            //     type: "GET",
            //     url:config.api.order_create,
            //     data:data.field,
            //     success: function(res) {
            //         if(res.code==1){
            //             layer.msg(res.msg, {icon:16, shade: 0.1, time:3000});
            //
            //             setTimeout(function () { location.href=res.data.redirect }, 1000);
            //         }else{
            //             layer.msg(res.msg);
            //         }
            //     }
            // });
            return false;
        });
    });
</script>
{/block}